<?php
namespace app\common\model;

use think\Model;
use app\common\model\GroupData;
class Group extends Model
{
    protected $autoWriteTimestamp =true;
    protected $type = [
        
        'create_time'  =>  'timestamp:Y/m/d H:i:s',
        'update_time'  =>  'timestamp:Y/m/d H:i:s',
        'totime'  =>  'timestamp:Y/m/d H:i:s',
        'endtime'  =>  'timestamp:Y/m/d H:i:s',
    
    ];
    
//    public function getValidateAttr($value){
//        $arr = [0=>'未提交审核',1=>'待审核',3=>'已审核',-1=>'未通过'];
//        return $arr[$value];
//    }
//
//    public function gettatusAttr($value){
//        $arr = [0=>'未上架',3=>'已上架'];
//        return $arr[$value];
//    }
    
    public function info(){
        return $this->hasMany('GroupData','group_id','id');
    }
    
    public function getInfo(){
        $list = GroupData::where('group_id',$this->id)->order('price asc')->field('id,price,stock,mall_id')->select();
        return $list;
    }
    
    public function goods(){
        return $this->hasOne('Goods','id','goods_id');
    }

}